/* SPDX-License-Identifier: GPL-2.0 */
/*
 * blknor_dev.h - nor block driver LomboTech
 * nor block driver driver code implement
 *
 * Copyright (C) 2016-2021, LomboTech Co.Ltd.
 * Author: lomboswer <lomboswer@lombotech.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __NORBLK_DEV_H
#define __NORBLK_DEV_H

struct norblk_geometry {
	int block_size;
	int block_cnt;
	struct norblk_operations *geom_ops;
};

struct norblk_operations {
	int (*read_block)(int start_block, int block_cnt, char *buf);
	int (*write_block)(int start_block, int block_cnt, char *buf);
};

struct norblk_device {
	char *name;
	int major;
	int minors;

	struct norblk_geometry *geometry;
	struct norblk_operations *ops;

	spinlock_t lock;
	struct request_queue *rq;
	struct gendisk *gd;

	struct workqueue_struct *wq;
	struct work_struct worker;
};

int norblk_register(struct norblk_geometry *geom);
void norblk_unregister(struct norblk_geometry *gemo);

#endif /* __NORBLK_DEV_H */

